package vn.muzik.interceptor;

import org.apache.log4j.Logger;

import vn.muzik.util.Log4jUtil;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

@SuppressWarnings("serial")
public class LoggingInterceptor extends AbstractInterceptor{
    private static Logger logger = Log4jUtil.getLogger();
    
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        final String actionName = invocation.getProxy().getConfig().getClassName();
        final String methodName = invocation.getProxy().getMethod();

        Log4jUtil.infoStartLog(logger, actionName + " # " + methodName);
        final String resultCode = invocation.invoke();
        Log4jUtil.infoFinishLog(logger, actionName + " # " + methodName);

        return resultCode;
    }

}
